﻿/*
-----------------------------------------------------------------------------
This source file is part of Cell Cloud.

Copyright (c) 2009-2012 Cell Cloud Team (cellcloudproject@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

#ifndef CellTalkCommand_h
#define CellTalkCommand_h

#include "CellPrerequisites.h"

namespace cell
{
/** \addtogroup Core
 *  @{
 */
/** \addtogroup General
 *  @{
 */

/** Talk 命令，仅用于服务端。
@author
	Jiangwei Xu
*/
class _CellPrivate TalkCommand : public GeneralAlloc
{
private:
	/**
	*/
	TalkCommand(void);

public:
	/**
	*/
	TalkCommand(TalkService* service);

	/**
	*/
	virtual ~TalkCommand(void);

public:
	/**
	*/
	virtual void execute(void) = 0;

protected:
	TalkService* mService;

public:
	// Status Code
	static const char SC_SUCCESSFUL[5];
	static const char SC_FAILED[5];
	static const char SC_FAILED_NOCELLET[5];
};


/** 校验 Session 合法性命令。
*/
class _CellPrivate TalkCheckCommand : public TalkCommand
{
public:
	/**
	*/
	TalkCheckCommand(TalkService* service, Session* session, Packet* packet);

	/**
	*/
	virtual ~TalkCheckCommand(void);

public:
	/**
	*/
	void execute(void);

private:
	Session* mSession;
	Packet* mPacket;
	char mTag[5];
};


/** 请求 Cellet 服务命令。
*/
class _CellPrivate TalkRequestCelletCommand : public TalkCommand
{
public:
	/**
	*/
	TalkRequestCelletCommand(TalkService* service, Session* session, Packet* packet);

	/**
	*/
	virtual ~TalkRequestCelletCommand(void);

public:
	/**
	*/
	void execute(void);

private:
	Session* mSession;
	Packet* mPacket;
	char mTag[5];
};


/** 对话命令。
*/
class _CellPrivate TalkDialogueCelletCommand : public TalkCommand
{
public:
	/**
	*/
	TalkDialogueCelletCommand(TalkService* service, Session* session, Packet* packet);

	/**
	*/
	virtual ~TalkDialogueCelletCommand(void);

public:
	/**
	*/
	void execute(void);

private:
	Session* mSession;
	Packet* mPacket;
	char mTag[5];
};


/** 代理数据传输命令。
*/
class _CellPrivate TalkProxyCommand : public TalkCommand
{
public:
	/**
	*/
	TalkProxyCommand(TalkService* service, Session* session, Packet* packet);

	/**
	*/
	virtual ~TalkProxyCommand(void);

public:
	/**
	*/
	void execute(void);

private:
	Session* mSession;
	Packet* mPacket;
	char mTag[5];
};


/** 网络心跳命令。
*/
class _CellPrivate TalkHeartbeatCommand : public TalkCommand
{
public:
	/**
	*/
	TalkHeartbeatCommand(TalkService* service, Session* session, Packet* packet);

	/**
	*/
	virtual ~TalkHeartbeatCommand(void);

public:
	/**
	*/
	void execute(void);

private:
	Session* mSession;
};

/** @} */
/** @} */
} // end namespace cell

#endif // CellTalkCommand_h
